package br.com.fiap.beans;

import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="quizz")
@SessionScoped
public class QuizzSimples {

    private ArrayList<Problema> problemas = new ArrayList<Problema>();
    private int score = 0;
    private int c = 0;

    public int getScore() {
        return score;
    }
    public QuizzSimples(){
        problemas.add(new Problema("{3,1,4,1}",5));
        problemas.add(new Problema("{0,1,0,1}",0));
        problemas.add(new Problema("{1,1,2,3,5}",8));
    }

    public String getSequencia(){
        if (c >= 2){
            c = 0;
        }
        else
        {
            c++;
        }
        return problemas.get(c).getSequencia();
        
    }

    public String getResposta(){
        return "";
    }

    public void setResposta(String resposta){
        Problema problemaAtual = problemas.get(c);
        int respostaDoUser = Integer.parseInt(resposta);
        if (respostaDoUser == problemaAtual.getSolução()){
            score++;
        } 
    }
}
